package com.neusoft.demo10;

import java.io.*;

public class CopyFileDemo1 {
    public static void main(String[] args) {
        try {
            FileReader fr = new FileReader("CopyFileDemo.java"); //节点流
            BufferedReader br = new BufferedReader(fr); //处理流用于对节点流功能的增强
            FileWriter fw = new FileWriter("NewCopyFileDemo.java");
            BufferedWriter bw = new BufferedWriter(fw);
            //读取源文件中的一行
            String s = br.readLine();
            while (s != null) {
                //将读取的文本写入到目标文件中
                bw.write(s);
                //换行
                bw.newLine();
                s = br.readLine();
            }
            //释放资源
            br.close();
            bw.close();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
